#ifndef WORLD_H
#define WORLD_H

#include "Scene.h"
#include <vector>

class World
{
	protected:
		Scene * current;
		std::vector<Scene*> scenes;
		std::string name;
	public:
		World(std::string name);
		~World();
		bool selectScene(Scene &scene);
		Scene * getSelectedScene() { return current; }
		void addScene(Scene &scene);
		void removeScene(Scene &scene);
		std::string getName() { return name; }
		std::vector<Scene*> getScenes() { return scenes; }
};

World::World (std::string name)
{ 
	World::name = name; 
}

World::~World()
{ 
	if (!current) 
	{
		delete current;
	}
}

bool World::selectScene(Scene &scene)
{
	for(int i = 0; i < scenes.size(); i++)
	{
		if((*scenes[i]).getType() == scene.getType() &&
			(*scenes[i]).getName() == scene.getName())
		{
			current = &scene;
			return true;
		}
	}
	return false;
}

void World::addScene(Scene &scene)
{
	scenes.push_back(&scene);
}

void World::removeScene(Scene &scene)
{
	for(int i = 0; i < scenes.size(); i++)
	{
		if((*scenes[i]).getType() == scene.getType() &&
			(*scenes[i]).getName() == scene.getName())
		{
			scenes.erase(scenes.begin() + i);
			return;
		}
	}
}

#endif